/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication1;

import java.io.*;

class String1 {

    static int wordcount(String s) {
        int i, count = 0;
        for (i = 0; i < s.length(); i++) {
            if (s.charAt(i) == ' ') {
                count++;
            }
        }
        count++;
        return count;
    }

    static int spacecount(String s) {
        int i, count = 0;
        for (i = 0; i < s.length(); i++) {
            if (s.charAt(i) == ' ') {
                count++;
            }
        }
        return count;
    }

    static int charcount(String s) {
        int i, count = 0;
        for (i = 0; i < s.length(); i++) {
            if (s.charAt(i) != ' ') {
                count++;
            }
        }
        return count;
    }

    static void reverse(String s) {
        int i, count = 0;
        for (i = s.length() - 1; i >= 0; i--) {
            System.out.print(s.charAt(i));
        }
    }

    static boolean palindrome(String s) {
        boolean b = true;
        int i, j;
        for (i = 0, j = s.length() - 1; i < j; i++, j--) {
            if (s.charAt(i) != s.charAt(j)) {
                b = false;
                break;
            }
        }
        return b;
    }

    static string ltrim(String s) {
    }

    static string rtrim(String s) {
    }

    static void sqeeze(String s) {
        char ar[] = new char[s.length()];
        int i, j = 0;
        char c;
        for (i = 0; i < s.length(); i++) {
            if (s.charAt(i) != ' ') {
                ar[j] = s.charAt(i);
                j++;
            }
        }
        System.out.println(ar);
    }

    static int vowelcount(String s) {
        int i, count = 0;
        for (i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'a' || s.charAt(i) == 'e' || s.charAt(i) == 'i' || s.charAt(i) == 'o' || s.charAt(i) == 'u') {
                count++;
            }
        }
        return count;
    }

    static int length(String s) {
        int i, count = 0;
        char ch[] = s.toCharArray();

        return ch.length;
    }

    static void sequencecount(String s) {
        int i, p = 0, j = 0, k = 0;
        char ch;

        int a[] = new int[s.length()];
        char c[] = new char[s.length()];

        for (i = 0; i < s.length(); i++) {
            a[i] = 0;

        }

        System.out.print("\n");

        for (i = 0; i < s.length(); i++) {
            c[j] = s.charAt(i);
            a[p]++;
            if (i != s.length() - 1) {
                if (s.charAt(i + 1) == c[j]) {
                    i++;
                    a[p] = a[p] + 1;
                }
            }
            System.out.println(c[j] + " " + a[p]);
            p++;
            j++;
        }

        System.out.println("This is frequency count:");
        for (i = 0; i < j; i++) {

            for (k = i + 1; k < j; k++) {
                if (c[i] == c[k] && c[k] != '0') {
                    a[i] = a[i] + a[k];
                    a[k] = 0;
                    c[k] = '0';
                }
            }
            System.out.println(c[i] + " " + a[i]);
        }
    }

    static String changecase(String s) {
    }

    public static void main(String k[])
            throws IOException {

        String s;

        System.out.println("Please enter any string ");

        BufferedReader br, br2;
        br = new BufferedReader(new InputStreamReader(System.in));
        s = br.readLine();

        System.out.println("These are the choices ");
        System.out.println("1.Word count \n2.Space count\n3.Character count\n4.Reverse a String\n5.Palindrome\n6.Left Trim\n7.Right Trim ");
        System.out.println("8.Sqeeze \n9.Vowel Count\n10.Length\n11.Sequence Count\n12.Frequency count\n13.Change Case \n14.Single Occurance  ");

        int choice;
        System.out.println("Enter your choice:");

        br2 = new BufferedReader(new InputStreamReader(System.in));
        choice = Integer.parseInt(br.readLine());


        switch (choice) {

            case 1:
                int d = wordcount(s);
                System.out.println(d);
                break;
            case 2:
                d = spacecount(s);
                System.out.println(d);
                break;
            case 3:
                d = charcount(s);
                System.out.println(d);
                break;
            case 4:
                reverse(s);
                break;
            case 5:
                boolean b = palindrome(s);
                System.out.println(b);
                break;
            case 6:
                ltrim(s);
                break;
            case 7:
                rtrim(s);
                break;
            case 8:
                sqeeze(s);
                break;
            case 9:
                d = vowelcount(s);
                System.out.println(d);
                break;
            case 10:
                d = length(s);
                System.out.println(d);
                break;
            case 11:
                sequencecount(s);
                break;
            case 12:
                frequencycount(s);
                break;
            case 13:
                changecase(s);
                break;
            case 14:
                singleoccurence(s);
                break;
            default:
                System.out.println("wrong choice");

        }

    }
}